/**
 * 加载国际化资源文件
 * 只加载一次
 * */
package cn.com.pkas.xml
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.external.ExternalInterface;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.xml.*;
	
	import mx.controls.Alert;

	public class URLLoader_ForResource extends Sprite 
	{		
			public function URLLoader_ForResource(){
				installResource();
			}
			[Bindable]
			public var BBSH:XML;
			public var LAN_ID:String = "zh_HK1";
			public function installResource() :void{
				// 如果已经加载过
				if(BBSH != null) {
					return;
				}
				Alert.show("1");
			     var loader:URLLoader = new URLLoader();
		    	 loader.addEventListener(Event.COMPLETE,completeHandler);
		         loader.load(new URLRequest(getUrl() + "view/common/resource.xml"));
		        
			}
			
			private function getUrl():String{  
		            var url:String = ExternalInterface.call("function getUrl(){return document.location.href;}");  
					return url;  
		    }  

			public function completeHandler(e:Event):void{
				BBSH= XML(e.target.data);
			}
			
			private function initRs(xml:XML):void{
				
				
				
			}
			
			[Bindable]
			public function getValue(key:String):String{
//				return key;
//				if(BBSH.resource.(@id==key).resourceValue.(@id==LAN_ID) == ""){
//					return key;
//				}
				return BBSH.resource.(@id==key).resourceValue.(@id==LAN_ID);
			}
    }

}